package us.icitap.commandcenter.business.ejb.persistence;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name="COMMAND_CENTER",schema="MPC")
public class CommandCenter implements Serializable {

	@Id
	@Column()
	private Integer id;
	
	@Column
	private String name;
	
	@Column(name="RECORD_USER")
	private String recordUser;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="RECORD_DATE")
	private Date recordDate;
	
	
	private boolean status;
	
	@OneToMany(mappedBy="commandCenter")
	private List<Dispatcher> dispatcherList;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}


	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}




	public String getRecordUser() {
		return recordUser;
	}

	public void setRecordUser(String recordUser) {
		this.recordUser = recordUser;
	}

	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}

	
	public List<Dispatcher> getDispatcherList() {
		return dispatcherList;
	}

	public void setDispatcherList(List<Dispatcher> dispatcherList) {
		this.dispatcherList = dispatcherList;
	}


	@Transient
	public List<Dispatcher> getActiveDispatcherList(){
		List<Dispatcher> list = new ArrayList<Dispatcher>();
		for (Dispatcher dispatcher : this.getDispatcherList()) {
			if(dispatcher.isStatus())
				list.add(dispatcher);
		}
		return list;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}
